<?php session_start(); $_SESSION['page'] = 'admin';?>
<!doctype html public "-//W3C//DTD HTML 4.01//EN">

<?php
    require('db_connection.php');
    $userType = $_COOKIE['userType'];

    if($userType == 'superadministrator')
    {
        $query = "SELECT * FROM tbladmin ORDER BY libraryNo";
    }
    else
    {
        $libraryNo = $_COOKIE['libraryNo'];
        $query = "SELECT * FROM tbladmin WHERE libraryNo=$libraryNo and userType='administrator' or userType='staff'";
    }
    $ctr=1;
    $result = mysql_query($query);
    $ctr1 = mysql_num_rows($result);
?>

<html>

   <head>
      <title>Administrator Result</title>
      <meta http-equiv="generator" content="PHP Designer 2005" />
      <style type="text/css">
        @import url(style.css);
      </style>
   </head>

   <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000" class=''>

    <table width='80%' align='center' class='content'>
        <tr><td colspan='2'><img src='images/banner.jpg'></td></tr>
        <tr><td align='right' colspan='2' class='logout'><?php require ('loginout.php');?></td></tr>
        <tr class='menuborder'><td width='90%'><img src='images/searchresult.png'></td><td><?php  require('buttons.php'); ?></td></tr>
        <tr><td colspan='2' class='bodyborder'>
        <?php echo "<form method='post' action='delete.php?page=admin&adminCtr=$ctr1'";?>
        <table align='center' cellspacing='0' width='80%'>
        <?php
            $ctr = 1;
            echo "<tr><td height='30'></td></tr>";
            echo "<tr class='listtable'><td></td><th width='20%'>User Name</th><th>Name</th><th>Library</th><th>Contact No</th></tr>";
            while ($row = mysql_fetch_array($result))
            {
              $adminID = $row['adminID'];
              $userName = $row['userName'];
              $lastName = $row['lastName'];
              $firstName = $row['firstName'];
              $contactNo = $row['contactNo'];
              $libraryNo = $row['libraryNo'];

              echo "<tr><td class='listborder'><input type='checkbox' name='admin[$ctr]' value=$adminID></td>";
              echo "<td class='listborder'><a href='admindetail.php?adminID=$adminID'>$userName</td>";
              echo "<td class='listborder'>$lastName, $firstName</td>";
              

              $querylib = "SELECT * FROM tbllibrary WHERE libraryNo='$libraryNo'";
              $resultlib = mysql_query($querylib);
              while ($row = mysql_fetch_array($resultlib))
              {
                    $libraryNo = $row['libraryNo'];
                    $libraryName = $row['libraryName'];
              }
          
              echo "<td class='listborder'>$libraryName</td>";
              echo "<td class='listborder'>$contactNo</td></tr>";
              $ctr++;
            }
              echo "<tr><td height='15'></td></tr>";
              echo "<tr><td colspan='5' align='right'><input type='submit' value='Delete' class='tool'>";
              echo "</form>";
        ?>
        </table>
        
            </td>
        </tr>
        <tr><td align='center' colspan='2'><?php require ('copyright.php')?></td></tr>
    </table>

   </body>
</html>



